/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/4/22
 * Time: 22:42
 */

#ifndef OBJECT_H
#define OBJECT_H
#include "Game.h"

class Object
{
public:
    enum class ObjectType
    {
        NONE,
        OBJECT_SCREEN,
        OBJECT_WORLD,
        ENEMY
    };

    Object() = default;

    virtual ~Object() = default;

    virtual void Init();
    virtual void Update(float _dt);
    virtual void Render();
    virtual void Clean();
    virtual void HandleEvent(SDL_Event & _event);

    virtual void AddChild(Object * _child);
    virtual void RemoveChild(Object * _child);

    void SafeAddChild(Object * _child) { object_to_add_.push_back(_child); }

    ObjectType GetType() const { return type_; }
    void       SetType(ObjectType type) { type_ = type; }

    bool IsActive() const { return is_active_; };
    void SetActive(bool _active) { is_active_ = _active; };

    bool NeedRemove() const { return need_remove_; }
    void SetNeedRemove(bool _need_remove) { need_remove_ = _need_remove; }

protected:
    Game &     game_ {Game::GetInstance()};
    ObjectType type_ {ObjectType::NONE};

    std::vector<Object *> children_;
    std::vector<Object *> object_to_add_;

    bool is_active_ {true};
    bool need_remove_ {false};
};

#endif//OBJECT_H
